package blackithei.UDP;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class ServerDemo3 {
    public static void main(String[] args) throws IOException {
        //寻找码头
        DatagramSocket ds=new DatagramSocket(10001);
        //创建包裹
        DatagramPacket dp=new DatagramPacket(new byte[1024],1024);
        //将码头的数据提取到包裹中
        ds.receive(dp);
        //将包裹中的数据提取出来
        byte[] data = dp.getData();
        int length = dp.getLength();
        System.out.println(new String(data,0,length));
        //释放资源
        ds.close();

    }
}
